<!-- 合同-合同设置-合同续签评估 -->
<template>
  <ContentCard>
    <template #header>
      <PageHeaderNew :title="title" showBack></PageHeaderNew>
    </template>
    <ConditionBox :margin-bottom="20" :margin-top="20">
      <template #left>
        <a-input-search
          :style="{ width: '220px' }"
          placeholder="名称"
          search-button
          @search="onSearch"
          @press-enter="onSearch"
          v-model="nameSearch"
        />
      </template>
      <template #right>
        <a-button type="primary" @click="add(null)" style="margin-right: 10px"
          >新增方案</a-button
        >
      </template>
    </ConditionBox>
    <table-turn :table-data="getTableData" ref="tableRef" :args="args">
      <a-table-column :width="80">
        <template #title> 序号 </template>
        <template #cell="{ rowIndex }">
          {{ rowIndex + 1 }}
        </template>
      </a-table-column>
      <a-table-column :width="200" data-index="name" title="记录表名称">
      </a-table-column>
      <a-table-column :width="200" data-index="definition" title="描述">
      </a-table-column>
      <a-table-column :width="200" data-index="definition" title="启用状态">
      </a-table-column>
      <a-table-column :width="200" data-index="" title="操作" fixed="right">
        <template #cell="{ record }">
          <a-tooltip content="编辑">
            <IconFont
              type="icon-edit"
              :size="26"
              :style="{
                marginRight: '10px',
                cursor: 'pointer'
              }"
              @click="goEdit(record)"
            />
          </a-tooltip>
          <a-tooltip content="删除" position="left">
            <a-popconfirm content="是否确认删除该条数据?" @ok="del(record.id)">
              <icon-font
                type="icon-delete"
                :size="26"
                :style="{
                  cursor: 'pointer',
                  marginRight: '10px'
                }"
              />
            </a-popconfirm>
          </a-tooltip>
        </template>
      </a-table-column>
    </table-turn>
  </ContentCard>
  <NoticeTemplate
    ref="templateRef"
    :data="currRecord.data"
    :add="addData"
    :business-type="businessType"
    :validateFun="validateName"
    :edit="EditData"
    :fn="tableRef"
    :title="`续签沟通表模板`"
  ></NoticeTemplate>
</template>

<script lang="ts" setup>
const router = useRouter();
const title = '合同续签评估';
let templateRef = ref();

// 表格配置
const args = {
  rowSelection: {
    type: 'checkbox',
    showCheckedAll: true,
    onlyCurrent: false
  }
};

let tableRef = ref();
let nameSearch = ref(''); // 搜索框值
// 储存当前数据
const currRecord: any = reactive({
  data: {}
});

// 获取表格数据
const getTableData = async () => {
  try {
    // originData.value = await GetHumanChangeSetting({
    //   typeId: 1 // 人事异动默认传1
    // });
    // const res: any = originData.value.find(
    //   (item: any) => item.id === currId.value
    // );
    // res.content = res.personnelChange;
    // return Promise.resolve(res.personnelChange);
  } catch (error: unknown) {
    console.log(error);
  }
};

const businessType = ref([
  'SER_FUNC218F8148FCD249D2A3791D31B02669C0',
  'baseComponent'
]);
// 新增
const add = (record?: any) => {
  currRecord.data = {
    name: '',
    enable: 1,
    remark: ''
  };
  templateRef.value.fullScreen();
};

const addData = async (data: any, componentList: any) => {
  try {
    //
  } catch (error: unknown) {
    console.log(error);
  }
};

const EditData = async (data: any, componentList: any) => {
  try {
    //
  } catch (error: unknown) {
    console.log(error);
  }
};

// 搜索框搜索事件
const onSearch = () => {
  refresh();
};

// 刷新表格数据
const refresh = () => {
  tableRef.value.loadData();
};
</script>

<style scoped lang="less">
.wrap {
  padding: 10px 20px;
  .header {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
  }
}
</style>
